package com.yx.cloud.network.ble.yg;

import com.yx.cloud.network.DataPacket;

import org.json.JSONException;
import org.json.JSONObject;

public class YGBleDataPacket extends DataPacket {
    public static int REAL_SIZE = 86;

    public byte packageSum;
    public byte order;

    public YGBleDataPacket(byte[] packData) {
        this.packData=packData;
    }

    @Override
    public int getCmd() {
        return 0;
    }

    @Override
    public int getOrder() {
        return order;
    }

    @Override
    public void setOrder(byte order) {
        this.order=order;
    }

    @Override
    public int getPacketSum() {
        return packageSum;
    }

    public void setPackageSum(byte packageSum) {
        this.packageSum = packageSum;
    }

    @Override
    public int getPacketLength() {
        return packData.length+1;
    }

    @Override
    public byte[] getContentData() {
        return packData;
    }

    public static boolean validateSlicePackage(byte[] packData) {
        if (packData == null) {
            //数据为空 抛弃
            return false;
        }
        String jsonString=new String(packData);
        try {
            JSONObject jsonObject=new JSONObject(jsonString);
        } catch (JSONException e) {
            e.printStackTrace();
            return false;
        }

        return true;
    }
}
